package com.etooling.framework.entity;


import com.etooling.framework.svo.AbstractEntity;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * 企业信息管理
 */
@Entity
@Table(name = "t_employee", schema = "framework")
public class Employee extends AbstractEntity {
    final public static String RUNNING_STATUS = "启用";
    final public static String STOP_STATUS = "停用";
    String name;
    List<Role> roles;//一个员工拥有多个角色
    Org org;//所属的机构
    transient String randCode;
    String sex;//性别
    String mobile;//联系方式
    Date createTime;//创建时间
    Date joinDate;//入职时间
    Double salary;//薪酬
    String isSuperUser;
    transient String pwd;//密码
    String loginId;//登录帐号
    String status;//状态
    AttachFile avatar;//头像

    String avatarUrl;
    String mainMachineId;
    String city;
    String country;
    String gender;
    String province;
    String appletsType;//小程序类型
    String mainCraftTypeId;//主工艺
    String companyId;

    List<PlatformAuth> platformAuths;//第三平台帐号

    public String getAvatarUrl() {
        return avatarUrl;
    }

    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = avatarUrl;
    }

    private String employeeCode;

    public String getEmployeeCode() {
        return employeeCode;
    }

    public void setEmployeeCode(String employeeCode) {
        this.employeeCode = employeeCode;
    }

    @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
    @Fetch(FetchMode.SUBSELECT)
    @JoinTable(name = "t_employee_platform_auth", schema = "framework", joinColumns = {@JoinColumn(name = "employee_id")}, inverseJoinColumns = {
            @JoinColumn(name = "platform_id")})
    public List<PlatformAuth> getPlatformAuths() {
        return platformAuths;
    }

    public void setPlatformAuths(List<PlatformAuth> platformAuths) {
        this.platformAuths = platformAuths;
    }

    @ManyToOne(targetEntity = Org.class, fetch = FetchType.EAGER)
    @JoinColumn(name = "org_id")
    public Org getOrg() {
        return org;
    }

    public void setOrg(Org org) {
        this.org = org;
    }

    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    public String getMainMachineId() {
        return mainMachineId;
    }

    public void setMainMachineId(String mainMachineId) {
        this.mainMachineId = mainMachineId;
    }

    public String getMainCraftTypeId() {
        return mainCraftTypeId;
    }

    public void setMainCraftTypeId(String mainCraftTypeId) {
        this.mainCraftTypeId = mainCraftTypeId;
    }


    public String getAppletsType() {
        return appletsType;
    }

    public void setAppletsType(String appletsType) {
        this.appletsType = appletsType;
    }


    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }


    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    @ManyToOne(targetEntity = AttachFile.class, fetch = FetchType.EAGER)
    @JoinColumn(name = "avatar_file_id")

    public AttachFile getAvatar() {
        return avatar;
    }

    public void setAvatar(AttachFile avatar) {
        this.avatar = avatar;
    }


    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getIsSuperUser() {
        return isSuperUser;
    }

    public void setIsSuperUser(String isSuperUser) {
        this.isSuperUser = isSuperUser;
    }

    public String getRandCode() {
        return randCode;
    }

    public void setRandCode(String randCode) {
        this.randCode = randCode;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
    @Fetch(FetchMode.SUBSELECT)
    @JoinTable(name = "t_employee_role", schema = "framework", joinColumns = {@JoinColumn(name = "employee_id")}, inverseJoinColumns = {
            @JoinColumn(name = "role_id")})
    public List<Role> getRoles() {
        return roles;
    }

    public void setRoles(List<Role> roles) {
        this.roles = roles;
    }


    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    public String getLoginId() {
        return loginId;
    }

    public void setLoginId(String loginId) {
        this.loginId = loginId;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Date getJoinDate() {
        return joinDate;
    }

    public void setJoinDate(Date joinDate) {
        this.joinDate = joinDate;
    }

    public Double getSalary() {
        return salary;
    }

    public void setSalary(Double salary) {
        this.salary = salary;
    }
}